export function fetchPOST(url, data) {
    const headers = { "Content-Type": "application/json" };
    const body = typeof data === 'string' ? data : JSON.stringify(data);
    const _fetch = fetch(url, { method: 'POST', headers: headers, body: body });
    return _fetch;
}

export function fetchGET(url) {
    const headers = { 'Content-Type': 'application/json' };
    const _fetch = fetch(url, { method: 'GET', headers: headers }).then((res) => {
        return res.json();
    });
    return _fetch;
}

export function reader(file, options = {}) {
    return new Promise((resolve, reject) => {
        let reader = new FileReader();
        reader.onload = function () {
            resolve(reader);
        };
        reader.onerror = reject;
        reader.readAsDataURL(file);
    })
}